
module.exports = {
    publicPath: process.env.NODE_ENV === "production" ? "./" : "/",
    lintOnSave: false, //关闭eslint格式化
    outputDir: "dist", //打包输出目录
    assetsDir: "assets", //静态资源目录
    indexPath: "index.html", //index路径
    filenameHashing: true, //文件名哈希

    devServer: {
        // host: "localhost",
        /* 本地ip地址 */
        //host: "192.168.1.107",
        host: "localhost", //局域网和本地访问
        port: "3000",
        hot: true,
        /* 自动打开浏览器 */
        open: false,
        /* 跨域代理 */
        proxy: {
          "/tophappiness": {
            /* 目标代理服务器地址 */
            // target: "http://192.168.199.234:29081",
            // target:'http://192.168.107.145:8080',
            target:'http://12345xcx.newhkic.cn',
            /* 允许跨域 */
            changeOrigin: true,
            ws: true,
            pathRewrite: {
              "^/tophappiness": "",
            },
          },
        },
    },
    chainWebpack: (config) => {
        config
            .module
            .rule("images")
            .test(/\.(jpg|png|gif)$/)
            .use("url-loader")
            .loader("url-loader")
            .options({
                limit: 10,
                publicPath: 'https://oss.xx.com/img',
                outputPath: 'img',
                name: '[name].[ext]',
            })
            .end();
    },
    chainWebpack: (config) => {
        const oneOfsMap = config.module.rule("less").oneOfs.store;
        oneOfsMap.forEach(item => {
            item
                .use("style-resources-loader")
                .loader("style-resources-loader")
                .options({
                    // 这里的路径不能使用 @ 符号，否则会报错
                    // patterns: ["./src/assets/reset1.less", "./src/assets/reset2.less"]
                    patterns: "./src/assets/css/common.less"
                })
                .end()
        })
    }
};
